<template>
  <div class="Rank">
    <h3>官方榜</h3>
    <RankList :list="result" :isShow="true" @allClick="allClick"></RankList>
    <h3>全球榜</h3>
    <MenuList :list="list" @itemClick="itemClick"></MenuList>
  </div>
</template>

<script>
import RankList from '@/components/list/RankList';
import MenuList from '@/components/list/MenuList';
export default {
  data() {
    return {
      result: [],
      list: '',
    };
  },
  computed: {},
  created() {
    this.getRankList();
  },
  components: { RankList, MenuList },
  methods: {
    async getRankList() {
      const { list } = await this.$request('/toplist');
      this.list = list.splice(4);
      list.forEach((item) => {
        this.getMenuDetail(item.id);
      });
    },
    async getMenuDetail(id) {
      const res = await this.$request('/playlist/detail', { id });
      res.playlist.tracks.splice(5);
      this.result.push(res.playlist);
    },
    //查看全部点击
    allClick(id) {
      this.$router.push('/songsmenudetail/' + id);
    },
    //榜单点击
    itemClick(id) {
      this.$router.push('/songsmenudetail/' + id);
    },
  },
};
</script>

<style scoped lang='scss'>
</style>